set(SOURCE_DIR ${PROJECT_ROOT}/driver/spi)
set(HEADER_DIR ${PROJECT_ROOT}/include/driver)

qelib_include_directories(${HEADER_DIR})

qelib_sources(
    ${SOURCE_DIR}/spi_core.c
    ${SOURCE_DIR}/spi_dev.c)

set(INSTALL_HEADERS
    ${HEADER_DIR}/qe_spi.h)

# spiflash
qelib_sources_ifdef(CONFIG_SPI_FLASH
    ${SOURCE_DIR}/spi_flash.c)
if(CONFIG_SPI_FLASH)
set(INSTALL_HEADERS ${INSTALL_HEADERS} ${HEADER_DIR}/qe_spi_flash.h)
endif()

qelib_sources_ifdef(CONFIG_SPI_FLASH_DRV
    ${SOURCE_DIR}/spi_flash_drv.c)

# Xilinx AXI QSPI
qelib_sources_ifdef(CONFIG_AXI_QSPI ${SOURCE_DIR}/axi_qspi.c)

# Xilinx PS7 QSPI
qelib_sources_ifdef(CONFIG_PS7_QSPI ${SOURCE_DIR}/ps7_qspi.c)

# Xilinx PS7 SPI
qelib_sources_ifdef(CONFIG_PS7_SPI ${SOURCE_DIR}/ps7_spi.c)

# Xilinx PSU QSPI
qelib_sources_ifdef(CONFIG_PSU_QSPI ${SOURCE_DIR}/psu_qspi.c)

install(FILES ${INSTALL_HEADERS} DESTINATION ${QELIB_INSTALL_PATH}/include/driver)